<template>
  <div>
    <h1>Student Check-In</h1>
    
    <el-table
      :data="list"
      style="width: 100%" 
    >
      <el-table-column
        prop="name"
        label="姓名"
        >
      </el-table-column>
      <el-table-column
        prop="score"
        label="匹配度"
        >
      </el-table-column>
      <el-table-column
        prop="created_at"
        label="时间"
        >
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getface } from '../api/results'
export default {
  data() {
    return {
      list : [],
    }
  },
  mounted() {
    this.gettoface()
  },
  methods: {
    async gettoface() {
      const res =await getface()
      console.log(res,1);
      // 处理返回的人脸数据
      this.list = res.data
      //时间处理
      this.list.forEach(item => {
        item.created_at = this.timeFormat(item.created_at)
      })
    },
    //时间处理
    timeFormat(time) {
      const date = new Date(time)
      return date.toLocaleString()
    },
    submitForm() {
      if (this.name && this.email) {
        console.log('Student checked in:', this.name, this.email)
      } else {
        alert('Please fill in all fields.')
      }
    }
  }
}
</script>
